<?php namespace App\Services;

use App\Facades\Infra\HotelInfoManager;
use App\Exceptions\DataBaseException;

class HotelInfoService{
	public function getInfo(){
		return HotelInfoManager::getHotelInfos($this->formatConditions());
	}

	public function createInfo($data){
		if($this->getInfo() != null){
			throw new DataBaseException('已存在数据');
		}

		HotelInfoManager::createHotelInfo($this->formatInfo($data));

		return;
	}

	public function updateInfo($data){
		HotelInfoManager::updateHotelInfo($this->formatConditions(),$data);
	}

	private function formatInfo($data){
		$data['hotel_id'] = \Auth::user()->id;

		return $data;
	}

	private function formatConditions(){
		$conditions['hotel_id'] = \Auth::user()->id;

		return $conditions;
	}
}